package com.sport.model.user.bos;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class AccountUserBo {

    /**
     * 运动会id(进行中的)
     */
    private Long sportId;

    /**
     * 租户id
     */
    private String schoolTenementId;
    /**
     * 运动会状态
     */
    private Integer sportStatus;

    /**
     * 线程副本
     */
    private static final InheritableThreadLocal<AccountUserBo> ACCOUNT_USER_BO_THREAD_LOCAL = new InheritableThreadLocal<>();

    /**
     * 添加用户
     * @param accountUserBo
     */
    public static Boolean saveUser(AccountUserBo accountUserBo) {

        if (accountUserBo == null)
            return false;

        ACCOUNT_USER_BO_THREAD_LOCAL.set(accountUserBo);

        return true;
    }

    /**
     * 获取用户
     * @return
     */
    public static AccountUserBo getUser() {
        return ACCOUNT_USER_BO_THREAD_LOCAL.get();
    }

    /**
     * 清理用户
     */
    public static void clear() {
        ACCOUNT_USER_BO_THREAD_LOCAL.set(null);
        ACCOUNT_USER_BO_THREAD_LOCAL.remove();
    }
}
